
{extend name='public/base' /}
{block name="css"}

{/block}
{block name="content"}

<div class="row">
    <div class="col-sm-12">
        <div class="ibox xiaoshi">
            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-12 search-collapse">
                        <form class="form-inline" id="user-form">
                            <div class="select-list">
                                <ul>
                                    {:li_input('qq名称','qq')}

                                    {:li_select(['1'=>'禁止','2'=>'正常'],'用户状态','status')}

                                    {:li_time()}

                                    {:li_search()}
                                </ul>
                            </div>
                        </form>
                    </div>

                </div>
            </div>
        </div>

        <div class="ibox">
            <div class="ibox-content">
                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-danger btn-rounded multiple {:node('article.ArticleUser/del')}" onclick="$.form.removeAll()">
                        <i class="fa fa-remove"></i> 删除
                    </a>
                    <a class="btn btn-warning btn-rounded" onclick="$.table.exportExcel()">
                        <i class="fa fa-download"></i> 导出
                    </a>
                </div>
                <div class="table-striped">
                    <table id="bootstrap-table" ></table>
                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"} <!--js处理区-->

<script>
    $(function() {
        var options = {
            url: "{:url('index')}",
            deleteUrl:  "{:url('del')}?id={id}", //删除链接
            exportUrl:  "{:url('export')}",  //导出
            updateUrl: "", //编辑
            addUrl:    "", //添加
            detailUrl:  "",    //详细
            sortName: "id",
            sortOrder: "desc",
            modalName: "用户",
            onEditableSave: onEditableSave, //行内编辑
            onDblClickRow:onDblClickRow, //双击行编辑
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID'
                },
                {
                    field : 'qq',
                    title : 'QQ',
                    align: 'center'
                },
                {
                    field : 'nickname',
                    title : '昵称',
                    align: 'center'
                },
                {
                    field : 'avatar',
                    title: '头像',
                    formatter: function(value, row, index) {
                        if($.common.isNotEmpty(row.avatar)){
                            return $.table.imageView(row.avatar);
                        }else {
                            return "-";
                        }
                    }
                },
                {
                    field: 'status',
                    title: '用户状态',
                    align: 'center',
                    editable : {
                        type : 'select',
                        title : '状态',
                        source : [{
                            value : 1,
                            text : '正常'
                        }, {
                            value : 0,
                            text : '禁用'
                        }]
                    }
                },

                {
                    field : 'os',
                    title : '系统'
                },
                {
                    field : 'browser',
                    title : '浏览器'
                },
                {
                    field : 'ip',
                    title : 'IP',
                    align: 'center'
                },
                {
                    field : 'zan',
                    title : '点赞数',
                    align: 'center'
                },
                {
                    field : 'fen',
                    title : '积分',
                    align: 'center'
                },
                {
                    field: 'create_time',
                    title: '添加时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return edit_del(row);
                    }

                }]
        };
        $.table.init(options);
    });

    function edit_del(row) {
            var actions = [];
            actions.push('<a class="btn btn-danger btn-xs {:node(\'article.ArticleUser/del\')}" data-original-title="删除" data-toggle="tooltip" onclick="$.form.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i></a>');
            return actions;
    }


    //双击行编辑
    function onDblClickRow(row) {
        // alert(JSON.stringify(row))
            $.form.edit(row.id);
    }
    function onEditableSave (field, row, oldValue) {
        $.form.Change_status("{:url('common/changeStatus')}","articles_user",row.id,field,row[field]);
    }
</script>

{/block}
